package date0603_1;

import java.time.LocalDate;

public class Person {

	private String name;
	private char gender;
	//建议使用 java.time.LocalDate 而不是使用 java.util.Date
	private LocalDate birthdate; // private Date birthdate ;
	private boolean married;

	public Person() {
		super();
	}

	public Person(String name, char gender, LocalDate birthdate, boolean married) {
		super();
		this.name = name;
		this.gender = gender;
		this.birthdate = birthdate;
		this.married = married;
	}
	

	@Override
	public String toString() {
		return "{ name : " + name + " , gender : " + gender +
					" , birthdate : " + ( birthdate == null ? "" : birthdate.toString() ) + " , married : " + married + " }";
	}
	
	public boolean marry( Person another ) {
		// 如何根据日期来获取一个人的年龄
		LocalDate today = LocalDate.now();
		int y1 = today.getYear(); // 获得年份
		int y2 = birthdate.getYear(); // 获得年份
		System.out.println( y1 - y2 ); // 当前Person对象的年龄
		
		// 其它代码省略
		
		return false ;
	}

	public String getName() {
		return name;
	}
	

	public char getGender() {
		return gender;
	}
	

	public LocalDate getBirthdate() {
		return birthdate;
	}
	

	public boolean isMarried() {
		return married;
	}
	

	public void setName(String name) {
		this.name = name;
	}
	

	public void setGender(char gender) {
		this.gender = gender;
	}
	

	public void setBirthdate(LocalDate birthdate) {
		this.birthdate = birthdate;
	}
	

	public void setMarried(boolean married) {
		this.married = married;
	}

}
